import random as r

x=[0,10]
y=[0,10]

class Turtle:
    def __init__(self):
        self.power=100
        self.x=r.randint(x[0],x[1])
        self.y=r.randint(y[0],y[1])

    def move(self):
        new_x=self.x + r.choice([1 , 2 , -1 , -2]) 
        new_y=self.y + r.choice([1 , 2 , -1 , -2])

        if new_x < x[0]:
            self.x = x[0]-(new_x-x[0])
        elif new_x > x[1]:
            self.x = x[1] - (new_x-x[1])
        else:
            self.x = new_x
        if new_y < y[0]:
            self.y = y[0] - ( new_y-y[0])
        elif new_y > y[1]:
            self.y = y[1] - (new_y - y[1])
        else:
            self.y = new_y

        self.power -= 1
        print("乌龟,[{0},{1}]".format(self.x,self.y))
        return (self.x,self.y)

    def eat(self):
        self.power+=20
        if self.power>100:
            self.power=100
        print(turtle.power)

class Fish:
    def __init__(self):
        self.x=r.randint(x[0],x[1])
        self.y=r.randint(y[0],y[1])

    def move(self):
        new_x=self.x + r.choice([1,-1])
        new_y=self.y + r.choice([1,-1])
        
        if new_x < x[0]:
            self.x = x[0]-(new_x-x[0])
        elif new_x > x[1]:
            self.x = x[1] - (new_x-x[1])
        else:
            self.x = new_x

        if new_y < y[0]:
            self.y = y[0] - ( new_y-y[0])
        elif new_y > y[1]:
            self.y = y[1] - (new_y - y[1])
        else:
            self.y = new_y

        return (self.x , self.y)

turtle = Turtle()
fish = []

for i in range(10):
    new_fish=Fish()
    fish.append(new_fish)
while True:
    if not len(fish):
        print("鱼都吃光啦，游戏结束！")
        break
    if not turtle.power:
        print("乌龟体力耗尽，挂掉了")
        break
    pos = turtle.move()
    for each_fish in fish[:]:
        if each_fish.move() == pos:
            turtle.eat()
            fish.remove(each_fish)
            print("有条鱼被吃掉了,还剩%d条" % len(fish))